package com.bangyu.monitor.core.util;

import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.TemplateEngineKind;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;

/**
 * @Auther: zhangxue
 * @Date: 19/5/27 20:30
 * @Description:
 */
@Slf4j
public enum ReportTemplateRegisterUtil {

    INSTANCE;

    public IXDocReport getTemplate(){
        InputStream in =
                ReportTemplateRegisterUtil.class.getResourceAsStream( "/report_template.docx" );
        try {
            return XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );
        } catch (Exception e) {
            log.error("get report template error",e);
            return null;
        }
    }

    public static void main(String[] args) {
        IXDocReport report = ReportTemplateRegisterUtil.INSTANCE.getTemplate();
        System.out.println(report.getId());
    }

}
